#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>

int main()
{

    pid_t id=fork();
    if(id == -1)
    {
        printf("子进程创建失败\n");
    }

    if(id == 0)
    {
        //子进程
        while(1)
        {
            printf("我是子进程，PID为%d，PPID为%d\n",getpid(),getppid());
            sleep(1);
        }
    }
    else 
    {
        //父进程
        while(1)
        {
            printf("我是父进程，PID为%d，子进程ID为%d\n",getpid(),id);
            sleep(1);
        }

    }


    return 0;
}
